package com;
public class SeqQueue {String element[];
    int front,rear;
    public SeqQueue(int length) {

        this.element=new String[length];
        this.front=this.rear=0;
    }
    public boolean isEmpty() {
        return this.front==this.rear;


    }
    public boolean add(String str) {

        if(this.front==(this.rear+1)%this.element.length) {
            String[] temp=this.element;
            this.element= new String[element.length*2];
            int j=0;
            for(int i=this.front;i!=this.rear;i=(i+1)%temp.length) {
                this.element[j++]=temp[i];
            }
            this.front=0;
            this.rear=j;
        }
        this.element[this.rear]=str;

        this.rear=(this.rear+1)%this.element.length;

        return true;
    }
    public String peek() {

        return this.isEmpty()?null:this.element[front];
    }
    public String poll() {
        if (isEmpty()) {
            return null;
        }
        int temp=this.front;
        this.front=(this.front+1)%this.element.length;
        return this.element[temp];
    }
}

